<!--
    -  Copyright (c) 2018-2025, haohanwork.com All rights reserved.
  -->
<template>
    <div class="execution">
        <basic-container>
            <avue-crud ref="crud"
                       :page.sync="page"
                       :data="tableData"
                       :table-loading="tableLoading"
                       :option="tableOption"
                       @on-load="getList"
                       @search-change="searchChange"
                       @refresh-change="refreshChange"
            >
                <template slot-scope="scope" slot="menu">
                    <el-button type="text"
                               v-show="scope.row.status==='0'"
                               @click="beginSettlement(scope.row)"
                               size="small">完成结算
                    </el-button>
                </template>
            </avue-crud>
        </basic-container>
    </div>
</template>
<!-- 结算记录 -->
<script>
    import {
        fetchList,
        completeSettlement
    } from '@/api/scm/finance/settlement_record'
    import {
        tableOption
    } from '@/const/crud/scm/finance/settlement/payable_list'
    import {getStore, setStore} from "@/util/store";
    export default {
        name: 'order',
        data() {
            return {
                tableData: [],
                page: {
                    total: 0, // 总页数
                    currentPage: 1, // 当前页数
                    pageSize: 20 // 每页显示多少条
                },
                tableLoading: false,
                tableOption: tableOption,
                pmId: '',
                settlementType: '2' // 结算类型为应付
            }
        },
        created() {
            this.pmId = getStore({name: "pmId"});
        },
        computed: {
        },
        methods: {
            // 设置公共参数
            commonParams(params){
                params.pmId = this.pmId;
                params.settlementType = this.settlementType;
                return params;
            },
            getList(page, params={}) {
                this.tableLoading = true
                params.current = page.currentPage;
                params.size = page.pageSize;
                this.commonParams(params);
                fetchList(params).then(response => {
                    this.tableData = response.data.data.records
                    this.page.total = response.data.data.total
                    this.tableLoading = false
                })
            },
            /**
             * 搜索回调
             */
            searchChange(form, done) {
                this.getList(this.page, form);
                done();
            },
            /**
             * 刷新回调
             */
            refreshChange(info) {
    this.getList(this.page, this.filterForm(info.searchForm));
},
            /**
             * 完成结算
             */
            beginSettlement(row) {
                this.$router.push({path: '/funds/settlement_detail', query: row});
            }
        }
    }
</script>

<style lang="scss" scoped>
</style>
